define(function (require, exports, module) {
	var OrderSwitchButton=function(selector,valueSelector,clickExport){
		this.element=$(selector).get(0)
		this.valueElement=$(valueSelector).get(0)
		this.clickExport=clickExport;
		
		var value=this.valueElement.value;
		this.setValue(value);
		var self=this;
		$(this.element).bind("click",function(event){self.clickHandle(event)})
	}
	OrderSwitchButton.prototype.value="desc"
	OrderSwitchButton.ORDER_DESC="desc"
	OrderSwitchButton.ORDER_ASC="asc"
	OrderSwitchButton.prototype.setValue=function(value){
		this.value=value;
		if(this.value==OrderSwitchButton.ORDER_DESC){
			$(this.element).addClass(OrderSwitchButton.ORDER_DESC);
			$(this.element).removeClass(OrderSwitchButton.ORDER_ASC);
		}else{
			$(this.element).addClass(OrderSwitchButton.ORDER_ASC);
			$(this.element).removeClass(OrderSwitchButton.ORDER_DESC);
		}
		this.valueElement.value=this.value
	}
	OrderSwitchButton.prototype.getValue=function(){
		return this.value;
	}
	OrderSwitchButton.prototype.switchValue=function(){
		if(this.getValue()==OrderSwitchButton.ORDER_DESC){
			this.setValue(OrderSwitchButton.ORDER_ASC)
		}else{
			this.setValue(OrderSwitchButton.ORDER_DESC)
		}
	}
	OrderSwitchButton.prototype.clickHandle=function(){
		this.switchValue();
		this.clickExport(this.getValue());
	}
	module.exports = OrderSwitchButton;
});